//
//  MainViewController.swift
//  LWGWB
//
//  Created by weiguang on 2017/1/2.
//  Copyright © 2017年 weiguang. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        addChildViewController(childVC: HomeViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(childVC: MessageViewController(), title: "消息", imageName: "tabbar_message_center")

        addChildViewController(childVC: discoverViewController(), title: "发现", imageName: "tabbar_discover")

        addChildViewController(childVC: ProfileViewController(), title: "我", imageName: "tabbar_profile")

    }
    
    //swift支持方法的重载
    //private 在当前文件中可以访问，其他文件不能访问
   private func addChildViewController(childVC: UIViewController,title : String,imageName : String) {
    
    //设置子控制器的属性
    childVC.title = title
    childVC.tabBarItem.image = UIImage(named: imageName)
    childVC.tabBarItem.selectedImage = UIImage(named: imageName+"_highlighted")
    
    //包装导航栏控制器
    let childNav = UINavigationController(rootViewController:childVC)
    
    //添加控制器
    addChildViewController(childNav)

    }
    
    
}
